home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / rot_int.pro < prev    next >
Text File  |  1997-07-08  |  3KB  |  111 lines

  1. ; $Id: rot_int.pro,v 1.3 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ; Copyright (c) 1982-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. FUNCTION ROT_INT, A, ANGLE, MAG, X0, Y0, CUBIC=cubic
  7. ;+
  8. ; NAME:
  9. ;    ROT_INT
  10. ;
  11. ; PURPOSE:
  12. ;    Rotate, magnify or demagnify, and/or translate an image with
  13. ;    bilinear interpolation.
  14. ;
  15. ;    Note that this function is made obsolete by the new ROT User
  16. ;    Library function which supports bilinear interpolation through
  17. ;    the use of the INTERP keyword.
  18. ;
  19. ; CATEGORY:
  20. ;    Z3 - Image processing, geometric transforms.
  21. ;
  22. ; CALLING SEQUENCE:
  23. ;    Result = ROT(A, Angle, [Mag, X0, Y0])
  24. ;
  25. ; INPUTS:
  26. ;    A:    The image array to be rotated.  This array may be of any type,
  27. ;        but it must have two dimensions.
  28. ;
  29. ;    ANGLE:    Angle of rotation in degrees CLOCKWISE. (Why?,
  30. ;        because of an error in the old ROT.)
  31. ;
  32. ; KEYWORD PARAMETERS:
  33. ;    CUBIC:    If set, uses "Cubic convolution" interpolation.  A more
  34. ;        accurate, but more time-consuming, form of interpolation.
  35. ;        CUBIC has no effect when used with 3 dimensional arrays.
  36. ;
  37. ; OPTIONAL INPUT PARAMETERS:
  38. ;    MAG:    Magnification/demagnification factor.  A value of 1.0 = no
  39. ;        change, > 1 is magnification and < 1 is demagnification.
  40. ;
  41. ;    X0:    X subscript for the center of rotation.  If omitted, X0 equals
  42. ;        the number of columns in the image divided by 2.
  43. ;
  44. ;    Y0:    Y subscript for the center of rotation.  If omitted, y0 equals
  45. ;        the number of rows in the image divided by 2.
  46. ;
  47. ; OUTPUTS:
  48. ;    ROT_INT returns a rotated, magnified, and translated version of the
  49. ;    input image.  Note that the dimensions of the output image are
  50. ;    always the same as those of the input image.
  51. ;
  52. ; COMMON BLOCKS:
  53. ;    None.
  54. ;
  55. ; SIDE EFFECTS:
  56. ;    None.
  57. ;
  58. ; RESTRICTIONS:
  59. ;    None.
  60. ;
  61. ; PROCEDURE:
  62. ;    The POLY_2D function is used to translate, scale, and
  63. ;    rotate the original image.
  64. ;
  65. ;    Note that bilinear interpolation is used by default (rather than
  66. ;    the nearest-neighbor method used by default in ROT).
  67. ;
  68. ; EXAMPLE:
  69. ;    Create and display an image.  Then display a rotated and magnified
  70. ;    version.  Create and display the image by entering:
  71. ;
  72. ;        A = BYTSCL(DIST(256))
  73. ;        TV, A
  74. ;
  75. ;    Rotate the image 33 degrees and magnify it 1.5 times.  Bilinear
  76. ;    interpolation is used to make the image look nice.  Enter:
  77. ;
  78. ;        B = ROT(A, 33, 1.5)
  79. ;        TV, B
  80. ;    
  81. ; MODIFICATION HISTORY:
  82. ;    June, 1982.     Written by DMS, RSI.
  83. ;
  84. ;    Feb, 1986.     Modified by Mike Snyder, ES&T Labs, 3M Company.
  85. ;             Adjusted things so that rotation is exactly on the 
  86. ;            designated center.
  87. ;
  88. ;    October, 1986.  Modified by DMS to use the POLY_2D function.
  89. ;    Nov, 1993.    DMS, RSI, Added CUBIC keyword.
  90. ;-
  91. ;
  92. ;
  93. ;
  94. on_error,2        ;Return to caller if error
  95. B = FLOAT(SIZE(A))    ;Get dimensions
  96. if b(0) ne 2 then begin
  97.     print,'ROT_INT - parameter must be 2d array'
  98.     return,undef
  99.     endif
  100.  
  101. IF N_PARAMS(0) LT 5 THEN BEGIN
  102.     X0 = (B(1)-1)/2.        ;Center of rotation in X.
  103.     Y0 = (B(2)-1)/2.        ; and in Y.
  104.     IF N_PARAMS(0) LT 3 THEN MAG = 1. ;Mag specified?
  105.     ENDIF
  106. ;
  107. ;            Use rot function
  108. return,rot(a, angle, mag, x0, y0, interp=1, CUBIC=KEYWORD_SET(cubic))
  109. END
  110.  
  111.